import request from '@/config/axios'

// 文章分类 VO
export interface MhCategoryVO {
  id: number // 分类编号
  parentId: number // 父分类编号
  name: string // 分类名称
  picUrl: string // 移动端分类图
  sort: number // 分类排序
  status: number // 开启状态
  tag: string // 标签
}

// 文章分类 API
export const MhCategoryApi = {
  // 查询文章分类分页
  getMhCategoryPage: async (params: any) => {
    return await request.get({ url: `/portal/mh-category/page`, params })
  },

  // 查询文章分类详情
  getMhCategory: async (id: number) => {
    return await request.get({ url: `/portal/mh-category/get?id=` + id })
  },

  // 新增文章分类
  createMhCategory: async (data: MhCategoryVO) => {
    return await request.post({ url: `/portal/mh-category/create`, data })
  },

  // 修改文章分类
  updateMhCategory: async (data: MhCategoryVO) => {
    return await request.put({ url: `/portal/mh-category/update`, data })
  },

  // 删除文章分类
  deleteMhCategory: async (id: number) => {
    return await request.delete({ url: `/portal/mh-category/delete?id=` + id })
  },

  // 导出文章分类 Excel
  exportMhCategory: async (params) => {
    return await request.download({ url: `/portal/mh-category/export-excel`, params })
  },

  // 获得商品分类列表
  getCategoryList : async (params: any) => {
    return request.get({ url: '/portal/mh-category/list', params })
  },
}
